`include "chunjun_define.sv" 
`include "chunjun_lib_define.sv" 
 
//--------------------------------------------------//
//---------------------AOMUX------------------------//
//--------------------------------------------------//
module wing_cbb_aomux #(
    parameter   NUM    = 16,
    parameter   WIDTH  = 16,
    parameter   type T = logic [WIDTH-1:0]
) (
    input   T     [NUM-1:0] data_arr,
    input   logic [NUM-1:0] sel_in_onehot0,
    output  T               data_sel
);

if (NUM == 1) begin : G_NUM1
 
assign data_sel = data_arr;
 
end else begin : G_NUM

localparam T_W = $bits(T);
 
logic [T_W-1:0][NUM-1:0]   data_arr_rotate;
logic [T_W-1:0]            data_sel_pre;

for (genvar i=0; i<NUM; i++) begin: G_ARR_MASKED
  for (genvar j=0; j<T_W; j++) begin : G_ROT_J
    assign data_arr_rotate[j][i] = data_arr[i][j] & sel_in_onehot0[i];
  end
end

for (genvar j=0; j<T_W; j++) begin: G_DATA_SEL
  assign data_sel_pre[j] = |data_arr_rotate[j][NUM-1:0];
end

assign data_sel = T'(data_sel_pre);
 
end // G_NUM
 
endmodule

`include "chunjun_undefine.sv" 
